<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
		<title>编辑资料</title>			
		<link rel="stylesheet" type="text/css" href="/azxcrm/css/wap/mui.min.css" th:href="@{/azxcrm/css/wap/mui.min.css}"/>
		<link rel="stylesheet" type="text/css" href="/azxcrm/css/wap/mui.picker.min.css" th:href="@{/azxcrm/css/wap/mui.picker.min.css}"/>
		<link rel="stylesheet" type="text/css" href="/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/aui.css}"/>
		<link rel="stylesheet" type="text/css" href="/azxcrm/css/wap/edit.css" th:href="@{/azxcrm/css/wap/edit.css}"/>
		<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_835360_5n3z54a5m1.css"/>
		<script src="/azxcrm/js/wap/mui.min.js" th:src="@{/azxcrm/js/wap/mui.min.js}" type="text/javascript" charset="utf-8"></script>
		<script src="/azxcrm/js/wap/mui.picker.min.js" th:src="@{/azxcrm/js/wap/mui.picker.min.js}" type="text/javascript" charset="utf-8"></script>
		<script src="/azxcrm/js/wap/city.data-3.js" th:src="@{/azxcrm/js/wap/city.data-3.js}" type="text/javascript" charset="utf-8"></script>
		<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
		<script th:inline="javascript"> var ctx = [[@{/}]]; </script>
	</head>
	<body>
		<header class="aui-bar aui-bar-nav">
			 <a href="javascript:history.back(-1)" class="aui-pull-left aui-btn">
	       		 <span class="iconfont icon-fanhui1">返回</span>
	    	</a>
		    <div class="aui-title">编辑资料</div>
		</header>
		<form id="edit_Customer">
		<section class="aui-grid aui-margin-b-15">
			<div class="aui-content aui-margin-b-15">
			    <ul class="aui-list aui-list-in">			       
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">真实姓名：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerName" name="customerName" th:value="${clue.customerName}">
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">手机号码：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerCellphone" name="customerCellphone"  th:value="${clue.customerCellphone}">
			                </div>
			            </div>
					</li>	
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">性别：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerSex" th:value="${clue.customerSex == 1?'男':'女'}">    
								<input type="hidden" id="customerSexs" name="customerSex" th:value="${clue.customerSex}"/>	
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">年龄：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerAge" name="customerAge" th:value="${clue.customerAge}">
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">身份证号：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerIdentityNum" name="customerIdentityNum" th:value="${clue.customerIdentityNum}">
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">出生日期：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="date" name="customerBirth" placeholder="请选择日期">
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">所在地：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="city" placeholder="请输入所在地" th:value="${clue.customerProvince}+'-'+${clue.customerCity}+'-'+${clue.customerArea}">
			                    <input type="hidden" id="customerProvince" name="customerProvince" th:value="${clue.customerProvince}"/>		   
			                    <input type="hidden" id="customerCity" name="customerCity" th:value="${clue.customerCity}"/>	
			                    <input type="hidden" id="customerArea" name="customerArea" th:value="${clue.customerArea}"/>
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">详细地址：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerAddressDetail" name="customerAddressDetail" th:value="${clue.customerAddressDetail}">
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">座机号码：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="" name="" th:value="${clue.customerPhone}">
			                </div>
			            </div>
					</li>
					<li class="aui-list-item">
			            <div class="aui-list-item-inner">
			                <div class="aui-list-item-label">微信号：</div>
			                <div class="aui-list-item-input">
			                    <input type="text" id="customerWechatAccount" name="customerWechatAccount" th:value="${clue.customerWechatAccount}">
			                </div>
			            </div>
					</li>
			    </ul>
			    
				<div class="aui-bar" id="footer">
					<input type="hidden" id="clueId" name="clueId" th:value="${clue.clueId}">
					<input type="hidden" id="status" name="status" th:value="${status}">
					<input type="hidden" id="orderId" name="orderId" th:value="${orderId}">
				    <button type="button" class="aui-bar" id="toastBtn" onclick="return check(this.form)">确认修改 </button>          
			   </div>
			</div>
		</section>
		</form>
	</body>
</html>
<script>
	var sex = document.getElementById('customerSex');
	var city = document.getElementById("city");
	var data = document.getElementById("date"); 
	var clueId = document.getElementById("clueId").value;
	var status = document.getElementById('status').value;
	var orderId = document.getElementById('orderId').value;
	var sex_data= new mui.PopPicker();
			sex_data.setData([{
						value: '1',
						text: '男',
					}, {
						value: '2',
						text: '女',
					}
				])
		sex.addEventListener('tap', function() {
			sex_data.show(function(items) {
				sex.value = items[0].text;
				document.getElementById('customerSexs').value = items[0].value;
				//返回 false 可以阻止选择框的关闭
				//return false;
			});
		}, false);	
		 var picker = new mui.PopPicker({layer: 3 });
           	picker.setData(cityData3)
			city.addEventListener('tap', function() {			
				 picker.show(function(items) {
			        city.value = items[0].text+'-'+items[1].text+'-'+items[2].text;		
			        document.getElementById('customerProvince').value = items[0].text;
			        document.getElementById('customerCity').value = items[1].text;
			        document.getElementById('customerArea').value = items[2].text;
			        
			      });
			})
		data.addEventListener('tap', function() {
			var picker = new mui.DtPicker({type:'date'});
		      picker.show(function(rs) {
		        data.value = rs.text;
		        picker.dispose();
		      });
		})	
	           	
       
       	function check(form) {
       	     var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
       	     if(form.customerName.value==''){
                 mui.toast('请输入姓名');
                 form.customerName.focus();
       		  }else if(form.customerCellphone.value=='') {              	  
	          	 mui.toast('请输入手机号码');
	             form.customerCellphone.focus();
            	 return false;                     
              }else if(!myreg.test(form.customerCellphone.value)) {
            	  debugger
               	 mui.toast('手机号码错误');
                  form.customerCellphone.focus();
                  return false;
             }else{
            	$.ajax({
         		cache : true,
         		type : "POST",
         		url : ctx + "/wap/customer/saveCustomer",
         		data : $("#edit_Customer").serialize(),
         		async : false,
         		error : function(request) {
         			mui.toast("系统错误", "error");
         		},
         		success : function(data) {
         			if (data.code == 0) {
         				$("#toastBtn").removeAttr("onclick");
         				mui.toast("修改成功"); 
         				setTimeout(function(){
	         				if(status==2){         				                		    	   
	           		    	    	window.location.href= ctx + "wap/customer/customerInfo?clueId=" + clueId+"&status=" + status            		    	 
	         				}else if(status == 0){       				                     
	                              window.location.href= ctx + "wap/wapOrderDetail?orderId=" + orderId+"&status=" + status                           
	         				}else if(status == 1){       					                      
	                              window.location.href= ctx + "wap/wapOrderDetail?orderId=" + orderId+"&status=" + status                           	
	         				}
         				},2200)
         				
         			} else {
         				mui.toast("修改失败");
         			}
         		}
         		});
             }     
       }
</script>